﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TelerikForms.PL
{
    public partial class Drawer : Form
    {
        public ChequeManagement.BLL.BLLDrawerFactory Fact1;
        ChequeManagement.BLL.BLLDrawer object1 ;
        DataTable D1;
        public Drawer()
        {
            InitializeComponent();
            Fact1 = new ChequeManagement.BLL.BLLDrawerFactory();
            object1 = new ChequeManagement.BLL.BLLDrawer();
            D1 = new DataTable();
        }

        private void Drawer_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'cmdbDataSet1.uspDrawerFetchAll' table. You can move, or remove it, as needed.
            this.uspDrawerFetchAllTableAdapter.Fill(this.cmdbDataSet1.uspDrawerFetchAll);
            // TODO: This line of code loads data into the 'cmdbDataSet.uspBankFetchAll' table. You can move, or remove it, as needed.
            this.uspBankFetchAllTableAdapter.Fill(this.cmdbDataSet.uspBankFetchAll);

        }

        private void Add_Click(object sender, EventArgs e)
        {
            object1.DrawerName = Name.Text;
            object1.Address = address.Text;
            object1.Tel = Tel.Text;
            Fact1.Add(object1);
            Fact1.GetAll(D1);
        }

        private void Update_Click(object sender, EventArgs e)
        {
            object1.DrawerName = Name1.Text;
            object1.Address = Address1.Text;
            object1.Tel = Tel1.Text;
            Fact1.Edit(object1,int.Parse(ID.Text));
        }

        private void Delete_Click(object sender, EventArgs e)
        {
            Fact1.Remove(int.Parse(ID.Text));
        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {
            if (SearchField.Text == "")
            {
                dataGridView1.DataSource = cmdbDataSet1.Tables[0];
            }
            else 
            {
                D1.Rows.Clear();
                Fact1.GetByField(ChequeManagement.BLL.BLLDrawer.DrawerField.DrawerName,SearchField, D1);
                dataGridView1.DataSource = D1;
            }
        }

    }
}
